package net.kingborn.erp.bc.command;

import net.kingborn.core.command.BaseCommand;
import net.kingborn.core.command.Command;
import net.kingborn.core.command.Param;
import net.kingborn.core.exception.Assert;
import net.kingborn.erp.bc.model.Sell;
import net.kingborn.erp.bc.service.SellService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 销货单审查
 */
@Command
public class CSellSwitchCheck extends BaseCommand {

    @Autowired
    private SellService sellService;

    @Param(required = true)
    private String sellId;
    
    @Override
    protected void init() throws Exception {

    }

    @Override
    protected void doCommand() throws Exception {
        Sell sell = sellService.getById(sellId);
        Assert.notNull(sell, "ID为【" + sellId + "】的销货订单不存在！");

        sell.setChecked(!sell.isChecked());
        sellService.saveOrUpdate(sell);

        data.put("sell", sell);
    }
}
